<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ListRegServlet.java</title>
<meta name="Generator" content="SciTE - www.Scintilla.org" />
<style type="text/css">
.S0 {
	color: #808080;
}
.S5 {
	font-weight: bold;
	color: #00007F;
}
.S6 {
	color: #7F007F;
}
.S10 {
	font-weight: bold;
	color: #000000;
}
span {
	font-family: 'Courier New';
	color: #000000;
	font-size: 9pt;
}
</style>
</head>
<body bgcolor="#FFFFFF">
<span><span class="S5">package</span><span class="S0"> </span>bbsimon<span class="S10">.</span>first<span class="S10">.</span>reg<span class="S10">;</span><br />
<br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>util<span class="S10">.*;</span><br />
<span class="S5">import</span><span class="S0"> </span>java<span class="S10">.</span>io<span class="S10">.*;</span><br />
<span class="S5">import</span><span class="S0"> </span>javax<span class="S10">.</span>servlet<span class="S10">.*;</span><br />
<span class="S5">import</span><span class="S0"> </span>javax<span class="S10">.</span>servlet<span class="S10">.</span>http<span class="S10">.*;</span><br />
<span class="S5">import</span><span class="S0"> </span>bbsimon<span class="S10">.</span>first<span class="S10">.</span>model<span class="S10">.</span>reg<span class="S10">.</span>RegModel<span class="S10">;</span><br />
<br />
<span class="S5">public</span><span class="S0"> </span><span class="S5">class</span><span class="S0"> </span>ListRegServlet<span class="S0"> </span><span class="S5">extends</span><span class="S0"> </span>HttpServlet<span class="S0"> </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">public</span><span class="S0"> </span><span class="S5">void</span><span class="S0"> </span>doPost<span class="S10">(</span>HttpServletRequest<span class="S0"> </span>req<span class="S10">,</span><span class="S0"> </span>HttpServletResponse<span class="S0"> </span>res<span class="S10">)</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">throws</span><span class="S0"> </span>IOException<span class="S10">,</span><span class="S0"> </span>ServletException<span class="S0"> </span><span class="S10">{</span><span class="S0"> </span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>res<span class="S10">.</span>setContentType<span class="S10">(</span><span class="S6">"text/html"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>PrintWriter<span class="S0"> </span>out<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>res<span class="S10">.</span>getWriter<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>RegModel<span class="S0"> </span>rm<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S5">new</span><span class="S0"> </span>RegModel<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>List<span class="S10">&lt;</span>String<span class="S10">&gt;</span><span class="S0"> </span>all<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>rm<span class="S10">.</span>list<span class="S10">();</span><br />
<br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>out<span class="S10">.</span>println<span class="S10">(</span><span class="S6">"&lt;html&gt;&lt;head&gt;&lt;title&gt;List all regs&lt;/title&gt;&lt;/head&gt;&lt;body&gt;"</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"&lt;h1&gt;all registered emails&lt;/h1&gt;&lt;ul&gt;"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>Iterator<span class="S0"> </span>it<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>all<span class="S10">.</span>iterator<span class="S10">();</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S5">while</span><span class="S10">(</span>it<span class="S10">.</span>hasNext<span class="S10">())</span><span class="S0"> </span><span class="S10">{</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>out<span class="S10">.</span>println<span class="S10">(</span><span class="S6">"&lt;li&gt;\""</span><span class="S0"> </span><span class="S10">+</span><span class="S0"> </span>it<span class="S10">.</span>next<span class="S10">()+</span><span class="S0"> </span><span class="S6">"\"&lt;/li&gt;"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>out<span class="S10">.</span>println<span class="S10">(</span><span class="S6">"&lt;/ul&gt;&lt;br&gt;&lt;a href=\"./\"&gt;Back to homepage&lt;/a&gt;"</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">+</span><span class="S0"> </span><span class="S6">"&lt;/body&gt;&lt;/html&gt;"</span><span class="S10">);</span><br />
<span class="S0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="S10">}</span><br />
<span class="S10">}</span><br />
<span class="S0"></span></span>
</body>
</html>
